package com.rookie.im.learn.io.netty.heartbeat.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.timeout.IdleStateEvent;

/**
 * Handles a server-side channel.
 */
public class HeartBeatClientHandler extends SimpleChannelInboundHandler<String> { // (1)

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
        System.out.println("========客户端" + channelHandlerContext.channel().remoteAddress() + "接收消息： " + s);
        if ("idle close".equals(s)) {
            System.out.println("服务端关闭");
            channelHandlerContext.channel().closeFuture();
        }
    }
}